#include <iostream>
#include <string>
#include <deque>

using namespace std;
class Stack {
public:
	// Push element x onto stack.
	void push(int x) {
		int size=queue.size();
		queue.push_back(x);
		for (int i=0;i<size;++i)
		{
			int tmp=queue.front();
			queue.push_back(tmp);
			queue.pop_front();
		}
	}

	// Removes the element on top of the stack.
	void pop() {
		queue.pop_front();
	}

	// Get the top element.
	int top() {
		return queue.front();
	}

	// Return whether the stack is empty.
	bool empty() {
		return queue.empty();
	}

private:
	deque<int> queue;
};

int main()
{
	Stack stk;
	stk.push(1);
	cout<<stk.top()<<endl;
	stk.push(3);
	cout<<stk.top()<<endl;
	stk.push(2);
	cout<<stk.top()<<endl;
	stk.pop();
	cout<<stk.top()<<endl;
}